package demo2;

import java.util.*;

public class Main {

    public static int n;
    public static int[][] dp = new int[110][110];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                int x = in.nextInt();
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + x;
            }
        }

        int ret = -127;
        for(int x1 = 1; x1 <= n; x1++){
            for(int y1 = 1; y1 <= n; y1++){
                for(int x2 = x1; x2 <= n; x2++){
                    for(int y2 = y1; y2 <= n; y2++){
                        ret = Math.max(ret, dp[x2][y2] - dp[x1 -1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1]);
                    }
                }
            }
        }
        System.out.println(ret);
    }

    public static void main2(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] s = in.next().toCharArray();

        int[] sum = new int[2];
        for(int i = 0; i < n; i++){
            sum[s[i] - '0']++;
        }

        int left = 0, right = 0, ret = 0, half = n / 2;
        int[] count = new int[2];
        while(right < n - 1){
            count[s[right] - '0']++;
            while(right -left + 1 > half){
                count[s[left++] - '0']--;
            }
            if(right -left + 1 == half){
                if(count[0] * 2 == sum[0] && count[1] * 2 == sum[1]){
                    ret += 2;
                }
            }
            right++;
        }
        System.out.println(ret);
    }
}
